import type { Response } from 'express';
import type { ApiResponse } from '../types/response';

export class ResponseUtil {
  static success<T>(res: Response, data: T, message: string = '操作成功') {
    const response: ApiResponse<T> = {
      code: 0,
      message,
      data
    };
    res.json(response);
  }

  static error(res: Response, message: string, code: number = -1) {
    const response: ApiResponse = {
      code,
      data: null,
      message
    };
    res.json(response);
  }
} 